def print_poem_perfect_center():
    # 诗词内容
    title = "          除夜怀远"
    author = "          作者: 张军"
    content = [
        "斑斓焰火映红天，锦绣椰城腾瑞烟。",
        "春晚鸣钟除旧岁，金龙赐福贺新年。",
        "可怜羁旅思乡远，但喜逍遥品酒绵。",
        "吾寄家书何处达？诚邀北雁复州边。"
    ]
    
    # 计算所有行的长度，找到最长的一行
    all_lines = [title, author] + content
    max_length = max(len(line) for line in all_lines)
    
    # 设定整体宽度为最长行+20（两侧各留10个字符的边距）
    total_width = max_length + 20
    
    # 打印标题（居中）
    print(title.center(total_width))
    
    # 打印作者（居中）
    print(author.center(total_width))
    
    # 打印空行分隔
    print()
    
    # 打印每句诗（居中）
    for line in content:
        print(line.center(total_width))

if __name__ == "__main__":
    print_poem_perfect_center()
